package com.jd.jstable.test;

import com.jd.jstable.annotation.HighAvailability;
import com.jd.jstable.annotation.HighPerformance;
import com.jd.jstable.config.KeyMode;
import org.springframework.stereotype.Service;

/**
 * Created by chenyipu on 2018/1/10.
 */
@Service
public class JimClass{
    private int i = 0;

    @HighAvailability(strategies = "_jim:SECONDS-2", key_mode = KeyMode.SOME_ARG, prefix = "B_B")
    public String b(int b){

        if(i >= 1){
            throw new RuntimeException("boom!");
        }
        System.out.println("run native code.");
        i++;
        return "here" + b;
    }

    @HighPerformance(strategies = "_jim:SECONDS-5,_redis")
    public String c(){

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("run native code c function.");
        return "there " + System.currentTimeMillis();
    }
}
